﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TalentRecruitmentSystem.Service;
using TalentRecruitmentSystem.Manage;

namespace TalentRecruitmentSystem.Pages
{
    public partial class BusinessRigister : System.Web.UI.Page
    {
        CompanyInfoManage cm = new CompanyInfoManage();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnCalendar_Click(object sender, EventArgs e)
        {

        }
        protected void EbtnLogin_Click(object sender, EventArgs e)
        {
            CompanyInfo companyInfo = new CompanyInfo();
            try
            {
                companyInfo.UserName = txtUserId.Text;
                companyInfo.Password = txtPooswd.Text;
                companyInfo.CompanyName = txtCpyName.Text;
                companyInfo.TradebBongTo = DdlIn.SelectedItem.ToString();
                companyInfo.WorkPlace = txtAd.Text;
                companyInfo.RegisterDate = DateTime.Parse(txtRigDate.Text);
                companyInfo.RegisterMoney = txtMoney.Text;
                companyInfo.EmployeeNumbers = int.Parse(txtNum.Text);
                companyInfo.ConcourNumber = int.Parse(TextBox1.Text);
                companyInfo.Publishposition = txtPosition.Text;
                companyInfo.DefiniteRequest = txtRequest.Text;
                companyInfo.WorkPlace = txtadr.Text;
                companyInfo.Companywebsite = txtWebite.Text;
                companyInfo.LinkPerson = txtPeople.Text;
                companyInfo.LinkPhone = txtMobleNomeber.Text;
                companyInfo.Email = txtCpEmail.Text;
                companyInfo.Role = "企业用户";
                cm.Add(companyInfo);
                Response.Write("<script>window.alert('用户名和密码不能为空！');</script>");
                Response.Redirect("Home.aspx?Name="+companyInfo.CompanyName);
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected void txtUserId_TextChanged(object sender, EventArgs e)
        {
            CompanyInfo companyInfo = cm.GetCompanyInfoByName(txtUserId.Text);
            if (companyInfo != null)
            {
                Response.Write("<script>window.alert('用户已存在！');</script>");
            }
        }
    }
}